package de.lulusoft.anothertorrent.gui.views.Providers;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import de.lulusoft.anothertorrent.core.rtorrent.Peer;
import de.lulusoft.anothertorrent.gui.util.Util;

public class PeersTableLabelProvider implements ITableLabelProvider {

	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof Peer)
		{
			Peer p = (Peer)element;
			switch (columnIndex)
			{
			case 0: return p.getAddress() + ":" + p.getPort().toString();
			case 1: return p.getClient_version();
			case 2: return p.getCompleted_percent().toString() + " %";
			case 3: return Util.formatBytes(p.getDown_rate());
			case 4: return Util.formatBytes(p.getUp_rate());
			case 5: return Util.formatBytes(p.getPeer_rate());
			case 6: return Util.formatBoolean(p.getEncrypted());
			case 7: return Util.formatBoolean(p.getObfuscated());
			case 8: return Util.formatBoolean(p.getIncoming());
			case 9: return Util.formatBoolean(p.getSnubbed());
			case 10: return p.getOptions_str();
			case 11: return p.getId();
			case 12: return Util.formatSeconds(p.getETA());
			case 13: return p.getComment();

			default: return "Not yet implemented";
			}
		}
		return "";
	}

	@Override
	public void addListener(ILabelProviderListener listener) {
	}

	@Override
	public void dispose() {
	}

	@Override
	public boolean isLabelProperty(Object element, String property) {
		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener listener) {
	}

}
